﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using Microsoft.SharePoint.Administration;

namespace SharePointCommander.Model.TreeView
{
    public class SCServiceApplication : SCTreeViewItem<SPServiceApplication>
    {
        public SCServiceApplication(SCTreeViewItem parent, SPServiceApplication application)
            : base(parent, application) 
        {
            Header = application.TypeName;
            Expanded += new System.Windows.RoutedEventHandler(SCServiceApplication_Expanded);
            ItemsSource = new object[] { null };
        }

        void SCServiceApplication_Expanded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!ItemsSource.OfType<SCProperties>().Any())
            {
                ItemsSource = new[] { new SCProperties(this, SPObject.Properties) as TreeViewItem };
            }
        }
    }
}
